#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>

//https://www.nowcoder.com/practice/fc533c45b73a41b0b44ccba763f866ef?tpId=13&&tqId=11209&rp=1&ru=/activity/oj&qru=/ta/coding-interviews/question-ranking

struct ListNode {
    int val;
    struct ListNode *next;
};

struct ListNode* deleteDuplication(struct ListNode* pHead) {
    struct ListNode *preHead = (struct ListNode *) malloc(sizeof(struct ListNode));
    struct ListNode *prev = preHead;
    struct ListNode *curr = pHead;
    preHead->next = pHead;
    while (curr) {
        struct ListNode *pack = curr;
        if (pack->val == pack->next->val && pack->next != NULL) {
            while (pack->next != NULL && pack->val == pack->next->val) {
                pack = pack->next;
            }
            prev->next = pack->next;
            curr = prev->next;
        } else {
            curr = curr->next;
            prev = prev->next;
        }
    }
    return preHead->next;
}


int main() {

    return 0;
}


